<template>
    <div class="e-form">
        <BillTop :title="$route.meta.title" @cancel="handleClose"></BillTop>
        <div class="tabs warningTabs"></div>
        <div class="tabs">
            <el-tabs tab-position="left" v-model="tabsName" @tab-click="onChangeTab">
                <el-tab-pane
                    label="基本信息"
                    name="baseInfo"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="招标包件信息"
                    name="package"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="企业主要业绩"
                    name="enterprise"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane label="资质信息" name="quaInfo" :disabled="clickTabFlag"></el-tab-pane>
                <div>
                    <div id="baseInfoCon" class="con">
                        <div class="tabs-title" id="baseInfo">基本信息</div>
                        <div style="width: 100%" class="form">
                            <el-form
                                ref="form"
                                :model="formData"
                                label-width="170px"
                                :rules="rules"
                            >
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="统一社会信用代码">
                                            <el-input
                                                v-model="formData.unitCode"
                                                placeholder="请先输入统一社会信用代码"
                                                @blur="unitCodeBlur(formData.unitCode)"
                                                :disabled="!auditState.canModify"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="投标单位">
                                            <el-input
                                                v-model="formData.unitName"
                                                :disabled="!auditState.canModify"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="法人代表">
                                            <el-input
                                                v-model="formData.legalRepresentative"
                                                :disabled="!auditState.canModify"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item
                                            label="注册资本（万元）"
                                            prop="registerCaptial"
                                        >
                                            <el-input
                                                v-model="formData.registerCaptial"
                                                :disabled="!auditState.canModify"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="资质等级">
                                            <el-input
                                                v-model="formData.qualificationLevelName"
                                                :disabled="!auditState.canModify"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="联系电话（手机）" prop="telephone">
                                            <el-input
                                                v-model="formData.telephone"
                                                :disabled="!auditState.canModify"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="传真">
                                            <el-input
                                                v-model="formData.fax"
                                                :disabled="!auditState.canModify"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="邮箱" prop="email">
                                            <el-input
                                                v-model="formData.email"
                                                :disabled="!auditState.canModify"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="纳税类别">
                                            <el-select
                                                v-model="formData.taxpayerType"
                                                placeholder="请选择"
                                                :disabled="unitCodeState"
                                            >
                                                <el-option
                                                    v-for="item in options2.taxpayerType"
                                                    :key="item.value"
                                                    :label="item.value"
                                                    :value="item.value"
                                                    :disabled="item.disabled"
                                                >
                                                </el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="是否境外单位：">
                                            <el-checkbox
                                                v-model="formData.isAbroad"
                                                :true-label="1"
                                                :false-label="0"
                                                :disabled="!auditState.canModify"
                                            ></el-checkbox>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row style="align-items: stretch">
                                    <el-col :span="24">
                                        <el-form-item label="地址：">
                                            <SelectAddr
                                                v-model="formData.registerAddress"
                                                lazy
                                                showCountry
                                                style="width: 100%"
                                                :disabled="!auditState.canModify"
                                            ></SelectAddr>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <ComNullify :formData="formData" />
                            </el-form>
                        </div>
                    </div>

                    <div id="packageCon" class="con e-table">
                        <div class="tabs-title" id="package">
                            <!-- <span style="color: red">*</span> -->
                            招标包件信息
                        </div>
                        <el-table
                            :data="packageTableData"
                            border
                            style="width: 100%"
                            :cell-class-name="cellClsNm"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            :max-height="$store.state.tableHeight"
            ref="table"
            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column width="200" prop="itemNo" label="包件号">
                            </el-table-column>
                            <el-table-column width="200" prop="name" label="包件名称">
                            </el-table-column>
                            <el-table-column
                                min-width="150"
                                prop="priceLimit"
                                label="招标最高限价（元）"
                            >
                            </el-table-column>
                        </el-table>
                    </div>

                    <div id="enterpriseCon" class="con e-table">
                        <div class="tabs-title" id="enterprise">
                            <!-- <span style="color: red">*</span> -->
                            企业主要业绩
                        </div>
                        <div>
                            <el-button
                                class="btn-greenYellow"
                                @click="enterpriseAdd(enterpriseTableData)"
                                :disabled="!auditState.canModify"
                                >新增</el-button
                            >
                            <el-button
                                class="btn-delete"
                                @click="deleteTableRow('enterpriseTableData')"
                                :disabled="!auditState.canModify"
                                >删除</el-button
                            >
                            <!-- <el-button @click="tableDel('enterprise')">删除行</el-button> -->
                        </div>
                        <el-table
                            :data="enterpriseTableData"
                            border
                            style="width: 100%; margin-top: 20px"
                            :cell-class-name="cellClsNm"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange"
                            :max-height="$store.state.tableHeight"
            ref="table"
            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column width="100" label="操作" type="selection">
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="contractName"
                                label="合同名称"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.contractName"
                                        placeholder="请输入内容"
                                        :disabled="!auditState.canModify"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="projectName"
                                label="项目名称"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.projectName"
                                        placeholder="请输入内容"
                                        :disabled="!auditState.canModify"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="contractAmount"
                                label="合同金额（元）"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.contractAmount"
                                        placeholder="请输入内容"
                                        :disabled="!auditState.canModify"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="workContent"
                                label="所承担工作内容"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.workContent"
                                        placeholder="请输入内容"
                                        :disabled="!auditState.canModify"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="startTime" label="开工时间">
                                <template slot-scope="{ row }">
                                    <el-date-picker
                                        v-model="row.startTime"
                                        type="date"
                                        placeholder="选择日期"
                                        value-format="yyyy-MM-dd"
                                        @blur="timeBlur(row)"
                                        :disabled="!auditState.canModify"
                                    >
                                    </el-date-picker>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="endTime" label="竣工时间">
                                <template slot-scope="{ row }">
                                    <el-date-picker
                                        v-model="row.endTime"
                                        type="date"
                                        placeholder="选择日期"
                                        value-format="yyyy-MM-dd"
                                        :picker-options="pickerOptions(row)"
                                        :disabled="!auditState.canModify"
                                    >
                                    </el-date-picker>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="personInCharge" label="项目负责人">
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.personInCharge"
                                        placeholder="请输入内容"
                                        :disabled="!auditState.canModify"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="witness"
                                label="业绩证明人"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.witness"
                                        placeholder="请输入内容"
                                        :disabled="!auditState.canModify"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="witnessPhone"
                                label="证明人电话"
                                label-class-name=""
                            >
                                <template slot-scope="{ row }">
                                    <el-input
                                        v-model="row.witnessPhone"
                                        placeholder="请输入内容"
                                        :disabled="!auditState.canModify"
                                    ></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column width="250" prop="proveFile" label="证明附件">
                                <template slot-scope="{ row }">
                                    <div class="affix">
                                        <el-upload
                                            ref="enterpriseUpload"
                                            v-if="row.recordId"
                                            :show-file-list="false"
                                            class="upload-demo"
                                            :action="ip"
                                            :headers="{
                                                token: userInfo.token,
                                                org: encodeURIComponent(
                                                    JSON.stringify(userInfo.orgInfo)
                                                )
                                            }"
                                            multiple
                                            :limit="1"
                                            :data="{
                                                bucketName: 'tender',
                                                relationId: row.recordId,
                                                orgCode: $store.state.userInfo.orgInfo.shortCode
                                            }"
                                            name="files"
                                            :before-upload="
                                                file => {
                                                    beforeAvatarUpload(file, row)
                                                }
                                            "
                                            :on-success="
                                                (response, file, fileList) => {
                                                    handleAvatarSuccess(
                                                        response,
                                                        file,
                                                        fileList,
                                                        row
                                                    )
                                                }
                                            "
                                            :disabled="!auditState.canModify"
                                        >
                                            <el-button size="mini" type="primary">上传</el-button>
                                        </el-upload>
                                        <div class="right">
                                            <div class="fileName">
                                                <a
                                                    :href="row.filePath"
                                                    target="_blank"
                                                    v-if="row.filePath && auditState.canModify"
                                                    >{{ row.fileName }}</a
                                                >
                                                <a v-else>{{ row.fileName }}</a>
                                            </div>
                                            <!-- 正好没返path，没附件id反正也删不掉 -->
                                            <i
                                                slot="reference"
                                                class="el-icon-delete"
                                                style="cursor: pointer; font-size: 20px"
                                                v-if="row.filePath"
                                                @click="delFile(row)"
                                            ></i>
                                        </div>
                                    </div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>

                    <div id="quaInfoCon" class="con e-table">
                        <div class="tabs-title" id="quaInfo">
                            <!-- <span style="color: red">*</span> -->
                            资质信息
                        </div>
                        <div>
                            <el-button
                                class="btn-greenYellow"
                                @click="quaInfoAdd(quaInfoTableData)"
                                :disabled="!auditState.canModify"
                                >新增</el-button
                            >
                            <el-button
                                class="btn-delete"
                                @click="deleteTableRow('quaInfoTableData')"
                                :disabled="!auditState.canModify"
                                >删除</el-button
                            >
                            <!-- <el-button type="success">下载</el-button> -->
                            <!-- <el-button @click="tableDel('quaInfo')">删除行</el-button> -->
                        </div>
                        <el-table
                            :data="quaInfoTableData"
                            border
                            style="width: 100%; margin-top: 20px"
                            :cell-class-name="cellClsNm"
                            @cell-click="cellClick"
                            @cell-mouse-enter="cellMouseEnter"
                            @cell-mouse-leave="cellMouseLeave"
                            @selection-change="selectionChange"
                            :max-height="$store.state.tableHeight"
            ref="table"
            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
                        >
                            <el-table-column width="100" label="操作" type="selection">
                            </el-table-column>
                            <el-table-column width="150" prop="certificateType" label="证书类型">
                                <template slot-scope="{ row }">
                                    <div v-if="row.frontState === 1">
                                        <el-select
                                            v-model="row.certificateType"
                                            placeholder="请选择"
                                            :disabled="!auditState.canModify"
                                        >
                                            <el-option
                                                v-for="item in options2.certificateType2"
                                                :key="item"
                                                :label="item"
                                                :value="item"
                                            >
                                            </el-option>
                                        </el-select>
                                    </div>
                                    <span v-else>{{ row.certificateType }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="certificateNo" label="证书编号">
                                <template slot-scope="{ row }">
                                    <div v-if="row.frontState === 1">
                                        <el-input
                                            v-model="row.certificateNo"
                                            placeholder="请输入内容"
                                            :disabled="!auditState.canModify"
                                        ></el-input>
                                    </div>
                                    <span v-else>{{ row.certificateNo }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                width="150"
                                prop="certificateGrade"
                                label="主营范围/资质等级"
                            >
                                <template slot-scope="{ row }">
                                    <div v-if="row.frontState === 1">
                                        <span>
                                            <el-input
                                                v-if="
                                                    row.certificateType === '营业执照' ||
                                                    row.certificateType === '资质证书'
                                                "
                                                readonly
                                                v-model="row.certificateGrade"
                                                placeholder="请选择"
                                            >
                                                <i
                                                    slot="suffix"
                                                    class="el-icon-document-copy"
                                                    @click="onSelect(row)"
                                                    style="cursor: pointer"
                                                ></i>
                                            </el-input>
                                        </span>
                                    </div>
                                    <span v-else>{{ row.certificateGrade }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="startTime" label="有效开始日期">
                                <template slot-scope="{ row }">
                                    <el-date-picker
                                        v-model="row.startTime"
                                        type="date"
                                        placeholder="选择日期"
                                        value-format="yyyy-MM-dd"
                                        @blur="timeBlur(row)"
                                        :disabled="!auditState.canModify"
                                    >
                                    </el-date-picker>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="endTime" label="有效结束日期">
                                <template slot-scope="{ row }">
                                    <span v-if="row.frontState === 1">
                                        <el-date-picker
                                            v-model="row.endTime"
                                            type="date"
                                            placeholder="选择日期"
                                            value-format="yyyy-MM-dd"
                                            :picker-options="pickerOptions(row)"
                                            style="width: 150px"
                                        >
                                        </el-date-picker>
                                        <el-button
                                            class="btn-blue"
                                            style="margin-left: 10px"
                                            size="mini"
                                            @click="forever(row, 'endTime')"
                                            >永久</el-button
                                        >
                                    </span>
                                    <span v-else>{{ row.endTime }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column width="150" prop="fileName" label="文件名">
                            </el-table-column>
                            <el-table-column width="150" prop="fileSize" label="大小">
                                <template slot-scope="{ row }" v-if="row.fileSize">
                                    {{ bytesToSize(row.fileSize) }}
                                </template>
                            </el-table-column>
                            <el-table-column width="200" prop="upTime" label="上传时间">
                            </el-table-column>
                            <el-table-column width="250" label="附件">
                                <template slot-scope="{ row }">
                                    <div class="affix">
                                        <el-upload
                                            ref="enterpriseUpload"
                                            v-if="row.recordId"
                                            :show-file-list="false"
                                            class="upload-demo"
                                            :action="ip"
                                            :headers="{
                                                token: userInfo.token,
                                                org: encodeURIComponent(
                                                    JSON.stringify(userInfo.orgInfo)
                                                )
                                            }"
                                            multiple
                                            :limit="1"
                                            :data="{
                                                bucketName: 'tender',
                                                relationId: row.recordId,
                                                orgCode: $store.state.userInfo.orgInfo.shortCode
                                            }"
                                            name="files"
                                            :before-upload="
                                                file => {
                                                    beforeAvatarUpload(file, row)
                                                }
                                            "
                                            :on-success="
                                                (response, file, fileList) => {
                                                    handleAvatarSuccess(
                                                        response,
                                                        file,
                                                        fileList,
                                                        row
                                                    )
                                                }
                                            "
                                            :disabled="!auditState.canModify"
                                        >
                                            <el-button
                                                size="mini"
                                                type="primary"
                                                v-if="!unitCodeState"
                                                >上传</el-button
                                            >
                                        </el-upload>
                                        <div class="right">
                                            <div class="fileName">
                                                <a :href="row.filePath" target="_blank">{{
                                                    row.fileName
                                                }}</a>
                                            </div>
                                            <i
                                                slot="reference"
                                                class="el-icon-delete"
                                                style="cursor: pointer; font-size: 20px"
                                                v-if="
                                                    row.fileName &&
                                                    !unitCodeState &&
                                                    auditState.canModify
                                                "
                                                @click="delFile(row)"
                                            ></i>
                                        </div>
                                    </div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                </div>
                <div style="font-weight: bold">
                    承诺：我代表公司承诺，上述信息正确、合法有效、若招标人（发起人）在招标过程中或中标后发现上述信息存在虚假、我们承诺承袒由此造成的所有责任（包括但不限于无条件故弃中标）。
                </div>
            </el-tabs>
        </div>
        <div class="buttons">
            <ComExaButtons
                :auditState="auditState"
                @exas="exas"
                :routeTo="
                    () => {
                        this.$router.push({
                            path: './equipmentBiddingApplicationEdit',
                            query: { billid: this.tenderId, seat: 'reg' }
                        })
                    }
                "
                :canDelete="false"
                :founderId="formData.founderId"
                :state="formData.state"
                :isPrint="false"
            />
            <el-button @click="handleClose">取消</el-button>
        </div>
        <div id="seat" :style="{ height: seatHeight + 'px' }"></div>
        <el-dialog
            :title="dialogTitle"
            :visible.sync="dialogVisible"
            width="50%"
            style="padding: 50px"
        >
            <span>
                <el-tree
                    :props="props"
                    :load="loadNode"
                    lazy
                    show-checkbox
                    style="margin-top: 20px"
                    @check-change="treeCheckChange"
                    :key="treeKey"
                >
                </el-tree>
            </span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="diaLogSubmit">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import '@/utils/jquery.scrollTo.min'
// import ComTreeTable from '@/templates/table/treeTable.vue'
// import ComTreeFile from '@/templates/table/treeFile.vue'
// import ComPagination from '@/components/pagination/pagination.vue'
import enrollRequest from '@/api/tender/enroll.js'
import equipmentProcurementRequest from '@/api/tender/equipmentProcurement.js'
import ossRequest from '@/api/oss/oss.js'
import { mapState } from 'vuex'
import SelectAddr from '@/components/common/addrComp'
// import { random19Num } from '@/utils/common'
import { ip } from '@/utils/request'
import { uidBuilder } from '@/api/base/uid.js'
import { bytesToSize } from '@/utils/common'
import openBiddingRequest from '@/api/tender/openBidding.js'
import call from '@/api/OutsourcingartyAdmin/getAllType.js'
import auditRequest from '@/api/tender/audit.js'
import commonRequest from '@/api/tender/common.js'
import ComExaButtons from '@/components/common/exaButtons'
import ComNullify from '@/pages/bidding/common/nullify.vue'
import { openAppClient } from '@/utils/common'
import { mapMutations } from 'vuex'

export default {
    data () {
        var isMobileNumber = (rule, value, callback) => {
            if (!value) {
                return new Error('请输入电话号码')
            } else {
                const reg = /^1[3|4|5|7|8][0-9]\d{8}$/
                const isPhone = reg.test(value)
                value = Number(value) //转换为数字
                if (typeof value === 'number' && !isNaN(value)) {
                    //判断是否为数字
                    value = value.toString() //转换成字符串
                    if (value.length < 0 || value.length > 12 || !isPhone) {
                        //判断是否为11位手机号
                        callback(new Error('手机号码格式如:138xxxx8754'))
                    } else {
                        callback()
                    }
                } else {
                    callback(new Error('请输入电话号码'))
                }
            }
        }
        var isEmail = (rule, value, callback) => {
            if (!value) {
                callback()
            } else {
                const reg =
                    /^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
                const email = reg.test(value)
                if (!email) {
                    callback(new Error('邮箱格式如:admin@163.com'))
                } else {
                    callback()
                }
            }
        }
        return {
            unitCodeState: false, // 信用代码是否通过状态，true全禁止，false可编辑
            unitCodeState2: true, // 信用代码通过，代理人、固定电话、联系电话、企业主要业绩可以编辑
            // 基础信息
            formData: {},
            cloneTableData: [],
            // 包件列表
            packageTableData: [],
            // 包件名字
            packageName: '',
            // 历史业绩
            enterpriseTableData: [],
            // 资质信息
            quaInfoTableData: [],
            upData: {
                bucketName: 'tender',
                relationId: ''
            },
            ip: ip + '/oss/uploader',
            selection: {},
            tenderData: {}, //基础招标信息
            managerTableData: [],
            attachTableData: [],
            // enterpriseFormData: [],
            tabsName: 'baseInfo',
            screenWidth: 0,
            screenHeight: 0,
            lastConHeight: 0,
            clickTabFlag: false, // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            form: {
                name: '',
                region: '',
                date1: '',
                date2: '',
                delivery: false,
                type: [],
                resource: '',
                desc: ''
            },
            tableData: [],
            value: '',
            textarea: '',
            test: '',
            selectData: [],
            selectTableColumnAttr: [
                {
                    label: '单据编号',
                    prop: 'billNo'
                },
                {
                    label: '拟招标项目名称',
                    prop: 'tenderName'
                },
                {
                    label: '单据日期',
                    prop: 'gmtCreate'
                },
                {
                    label: '单据机构名称',
                    prop: 'orgName'
                }
            ],
            selectTableColumnWidth: {
                leftWidth: '150',
                rightWidth: '100'
            },
            selectDataPagination: {},
            fileList4: [],
            typeList: [],
            payTaxesTypeList: [],
            auditState: {},
            auditParams: {
                billId: this.$route.query.billid,
                billType: 60283,
                freeNextUnitIndex: 0,
                freeNextUser: '',
                isPass: true,
                isShareInAudit: true,
                opinion: ''
            },
            nullifyParams: {
                billId: this.$route.query.billid,
                billType: 60283,
                nullifyCreated: '',
                nullifyCreator: '',
                nullifyCreatorId: '',
                nullifyDescription: '',
                nullifyReason: ''
            },
            cloneMapEnterpriseTableData: new Map(),
            cloneMapQuaInfoTableData: new Map(),
            deleteTable: {
                quaInfoTableData: [],
                enterpriseTableData: []
            },
            pickerOptions: row => {
                return {
                    disabledDate (time) {
                        return time.getTime() < new Date(row.startTime).getTime() + 86400000
                    }
                }
            },
            rules: {
                registerCaptial: {
                    type: 'number',
                    message: '请输入数字',
                    trigger: 'blur'
                },
                telephone: { validator: isMobileNumber, trigger: 'blur' },
                email: { validator: isEmail, trigger: 'blur' }
            },
            dialogVisible: false,
            dialogTitle: '',
            props: {
                label: 'kvValue',
                // children: 'zones',
                isLeaf: 'isLeaf'
            },
            treeCheckSet: new Set(),
            row: null, //资质信息 主营范围/资质等级 回调弹窗保存的当前row
            treeKey: 0
        }
    },
    computed: {
        ...mapState({
            options2: state => state.biddingApplication.openDictionaries,
            options: state => state.biddingApplication.dictionaries
        }),
        // ...mapState({
        //     options: state => state.biddingApplication.openDictionaries
        // }),
        ...mapState(['userInfo']),
        tenderId () {
            // return this.formData.tenderApplyId
            return this.$route.query.tenderId || this.$route.query.billid //假数据
        },
        billId () {
            return this.$route.query.billId || this.$route.query.billid
        },
        // 填补底部空白，以使高度够滚动
        seatHeight () {
            return this.screenHeight - 72 - this.lastConHeight
        }
    },
    components: {
        // ComTreeTable,
        // ComTreeFile,
        // ComPagination,
        SelectAddr,
        ComExaButtons,
        ComNullify
    },
    async created () {
        // 基本信息
        await this.getData()
        // 外包方类型、纳税人类别
        this.getTypeData()
        // 审核按钮状态
        this.getCurrentUnitInfo()
        // 资质信息
        this.getQuaInfoTableData()
        // 历史业绩
        this.getEnterpriseTableData()
        this.getPackage() // 获取包件信息
    },
    mounted () {
        // 保存所有tabName
        const arr = ['baseInfo', 'package', 'enterprise', 'quaInfo', 'manager', 'attach']
        // 获取最后一个内容区域的高度，计算底部空白
        this.getLastConHeight(arr)
        let $idsTop = []
        window.addEventListener('scroll', () => {
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            if (this.clickTabFlag) {
                return
            }
            if (!$idsTop[$idsTop.length - 1]) {
                $idsTop = arr.map(item => {
                    const itemTop = document.getElementById(item)?.offsetTop
                    return itemTop
                })
            }
            const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
            // 倒序查找
            let curLocal = 0
            for (let len = $idsTop.length, i = len - 1; i >= 0; i--) {
                let item = $idsTop[i]
                if (scrollTop + 1 >= item) {
                    curLocal = i
                    break
                }
            }
            // 设置对应tabName
            this.tabsName = arr[curLocal]
        })

        this.screenWidth = document.documentElement.clientWidth - this.topHeight
        this.screenHeight = document.documentElement.clientHeight - this.topHeight
        window.addEventListener('resize', () => {
            this.screenWidth = document.documentElement.clientWidth - this.topHeight
            this.screenHeight = document.documentElement.clientHeight - this.topHeight
            $idsTop = arr.map(item => {
                const itemTop = document.getElementById(item)?.offsetTop
                return itemTop
            })
        })
    },
    beforeDestroy () {
        this.$notify.closeAll()
    },
    methods: {
        ...mapMutations(['setAuditParams']),
        diaLogSubmit () {
            this.dialogVisible = false
            this.row.certificateGrade = [...this.treeCheckSet].join(',')
        },
        treeCheckChange (data, isCheck) {
            if (isCheck) {
                this.treeCheckSet.add(data.kvValue)
            } else {
                this.treeCheckSet.delete(data.kvValue)
            }
        },
        async loadNode (node, resolve) {
            console.log('this.dialogTitle', this.dialogTitle)
            if (node.level === 0) {
                const dicName = this.dialogTitle.includes('资质等级')
                    ? '资质等级'
                    : '外包方主营范围'
                const res = await commonRequest.getDicValueTree({
                    dicName,
                    isEnable: true,
                    parentId: 0
                })
                return resolve(res)
            }
            if (node.level >= 1) {
                const dicName = this.dialogTitle.includes('资质等级')
                    ? '资质等级'
                    : '外包方主营范围'
                const res = await commonRequest.getDicValueTree({
                    dicName,
                    isEnable: true,
                    parentId: node.data.kvId
                })
                return resolve(res)
            }
        },
        onSelect (row) {
            // 需要刷新 主营范围/证书等级 接口
            this.treeKey += 1
            // 弹窗后需要改变，所以保存
            this.row = row
            this.dialogVisible = true
            console.log('row.certificateType', row.certificateType)
            this.dialogTitle =
                row.certificateType === '营业执照' ? '请选择主营范围' : '请选择资质等级'
        },
        forever (row, name) {
            row[name] = '9999-12-30'
        },
        timeBlur (row) {
            if (new Date(row.startTime).getTime() > new Date(row.endTime).getTime()) {
                row.endTime = null
            }
        },
        deleteTableRow (tableName) {
            if (this.selection[tableName].length === 0) return
            this.selection[tableName].forEach(item => {
                // 记录进delete表
                if (item.changeType !== 1) {
                    item.changeType = -1
                    this.deleteTable[tableName].push(item)
                }
                // 前端删除
                const deleteIndex = this[tableName].findIndex(
                    item2 => (item.recordId = item2.recordId)
                )
                this[tableName].splice(deleteIndex, 1)
            })
        },
        selectionChange (tabaleName, selection) {
            this.selection[tabaleName] = selection
        },
        async getCurrentUnitInfo () {
            if (
                this.formData.state === -1 ||
                this.formData.state === 2 ||
                this.formData.state === 5
            )
                return
            await auditRequest.getCurrentUnitInfo(this.auditParams).then(res => {
                this.auditState = res
            })
        },
        handleClose () {
            this.$router.push({
                path: './equipmentBiddingApplicationEdit',
                query: { billid: this.tenderId, seat: 'reg' }
            })
        },
        ifSeat () {
            if (this.$route.query.seat) {
                this.tabsName = this.$route.query.seat
                this.onChangeTab(this.$route.query.seat)
            }
        },
        async exas (arg, routeTo) {
            if (arg === 'audit') {
                this.saveAllData(false)
                this.setAuditParams(this.auditParams)
                // 客户端弹窗弹出本地页面
                openAppClient('/exaDialog', '填写审核意见', () => {
                    const auditParams = JSON.parse(localStorage.vuex).auditParams
                    if (auditParams.opinion === '') {
                        this.clientPop('err', '审核意见未填')
                        return
                    }
                    auditRequest.audit(auditParams).then(() => {
                        if (auditParams.isPass) {
                            this.clientPop('suc', '审核成功', routeTo)
                        } else {
                            this.clientPop('suc', '返回修改成功', routeTo)
                        }
                        this.getCurrentUnitInfo()
                        this.getData()
                        this.$refs.ComExaHistory.getAuditHistory()
                        this.$refs.ComBidButtons.getButtonState() // 刷新招标按钮
                    })
                }, null, null, null, 'small')
            } else if (arg === 'undoAudit') {
                this.clientPop('info', '确定要撤回上一步审核操作吗？', () => {
                    auditRequest.undoAudit(this.auditParams).then(() => {
                        this.clientPop('suc', '撤回成功', routeTo)
                        this.getData() // 刷新基础信息
                        this.getCurrentUnitInfo()
                        this.getData()
                        this.$refs.ComExaHistory.getAuditHistory()
                    })
                })
            } else if (arg === 'submitCommit') {
                // 保存所有信息
                const promise1 = await this.saveAllData(false)
                //   审核
                const promise2 = auditRequest.commit(this.auditParams)
                await Promise.all([promise1, promise2]).then(() => {
                    this.clientPop('suc', '保存并提交成功', routeTo)
                    this.getCurrentUnitInfo()
                    this.getData()
                    this.$refs.ComExaHistory.getAuditHistory()
                })
                // 重置
                this.loadComponent = new Set()
                this.getData()
                this.$route.query.seat = this.tabsName
                this.ifSeat()
            } else if (arg === 'submit') {
                await this.saveAllData()
                // 重置
                this.$route.query.seat = this.tabsName
                this.ifSeat()
            } else if (arg === 'nullify') {
                this.setAuditParams(this.nullifyParams)
                // 客户端弹窗弹出本地页面
                openAppClient('/nullifyDialog', '单据作废原因', () => {
                    const auditParams = JSON.parse(localStorage.vuex).auditParams
                    commonRequest.nullify(auditParams).then(() => {
                        this.clientPop('suc', '作废成功', routeTo)
                        this.getCurrentUnitInfo()
                        this.getData()
                        this.$refs.ComExaHistory.getAuditHistory()
                    })
                }, null, null, null, 'small')
            } else if (arg === 'deleteData') {
                this.clientPop('info', '确定要删除吗？数据删除后不可恢复，请谨慎操作！', () => {
                    equipmentProcurementRequest.applyDelete({ id: this.tenderId }).then(() => {
                        const callBack = () => {
                            this.$router.push('./materialBiddingApplication')
                        }
                        this.clientPop('suc', '删除成功', callBack)
                    })
                })
            }
        },
        //获取分包商类型数据
        getTypeData () {
            call.getCredentialTree({ name: '外包方类型', id: '0' }).then(res => {
                let id = ''
                // 获取想要的类型id
                res.map(item => {
                    if (item.kvKey == '分包商') {
                        id = item.kvId
                    }
                })
                call.getCredentialTree({ name: '外包方类型', id: id }).then(res => {
                    this.typeList = res
                    console.log('this.typeList', this.typeList)
                })
                call.getCredential('纳税类别').then(res => {
                    this.payTaxesTypeList = res
                    console.log('this.payTaxesTypeList', this.payTaxesTypeList)
                })
            })
        },
        // 历史业绩
        getQuaInfoTableData () {
            equipmentProcurementRequest
                .achievementHistoryList({ billId: this.billId })
                .then(res => {
                    this.enterpriseTableData = res
                    this.enterpriseTableData.forEach(item => {
                        delete item.changeType
                        this.cloneMapEnterpriseTableData.set(item.recordId, JSON.stringify(item))
                        item.frontState = 1
                        item.changeType = 0
                    })
                })
        },
        // 资质信息
        getEnterpriseTableData () {
            equipmentProcurementRequest
                .certificateListByEntity({ billId: this.billId })
                .then(res => {
                    this.quaInfoTableData = res
                    this.quaInfoTableData.forEach(item => {
                        delete item.changeType
                        this.cloneMapQuaInfoTableData.set(item.recordId, JSON.stringify(item))
                        item.frontState = 1
                        item.changeType = 0
                    })
                })
        },
        async getData () {
            await equipmentProcurementRequest.erollGetById({ id: this.billId }).then(res => {
                this.formData = res
                this.cloneTableData = JSON.parse(JSON.stringify(res))
                console.log('this.formData.outsourceType', this.formData.outsourceType)
                if (this.formData.outsourceType === null) {
                    this.formData.outsourceType = []
                } else {
                    this.formData.outsourceType = this.formData.outsourceType.split(',')
                }
            })
        },
        ifEdit (newObj, oldObjStr) {
            // 新增数据不判断
            if (newObj.changeType === 1) return
            // 不影响原数据
            const temp = JSON.parse(JSON.stringify(newObj))
            delete temp.changeType
            delete temp.frontState
            if (JSON.stringify(temp) !== oldObjStr) {
                newObj.changeType = 2
            } else {
                newObj.changeType = 0
            }
        },
        async saveAllData () {
            // 基础信息
            console.log('this.formData', this.formData)
            // const promise1 = await equipmentProcurementRequest.erollUpdate(this.formData)
            // 资质信息
            // 处理changeType
            // this.quaInfoTableData.forEach(item => {
            //     this.ifEdit(item, this.cloneMapQuaInfoTableData.get(item.recordId))
            // })
            // const quaInfoTableData = [
            //     ...this.quaInfoTableData,
            //     ...this.deleteTable['quaInfoTableData']
            // ]
            // console.log('quaInfoTableData', quaInfoTableData)
            // const promise2 = equipmentProcurementRequest.certificateCreate(quaInfoTableData)
            // // 历史业绩
            // // 处理changeType
            // this.enterpriseTableData.forEach(item => {
            //     this.ifEdit(item, this.cloneMapEnterpriseTableData.get(item.recordId))
            // })
            // const enterpriseTableData = [
            //     ...this.enterpriseTableData,
            //     ...this.deleteTable['enterpriseTableData']
            // ]
            // console.log('enterpriseTableData', enterpriseTableData)
            // const promise3 =
            //     equipmentProcurementRequest.achievementHistoryCreate(enterpriseTableData)
            // Promise.all([promise2, promise3]).then(() => {
            //     this.clientPop('suc', '保存成功')
            //     // 基本信息
            //     this.getData()
            //     // 资质信息
            //     this.getQuaInfoTableData()
            //     // 历史业绩
            //     this.getEnterpriseTableData()
            // })
        },
        bytesToSize (byte) {
            return bytesToSize(byte)
        },
        async delFile (row) {
            await ossRequest.deleterByRelationId({ relationId: row.recordId }).then(() => {
                row.fileName = ''
                row.filePath = ''
                row.fileSize = ''
            })
        },
        // 上传成功后
        handleAvatarSuccess (response, file, fileList, row) {
            const res = response.data[0]
            row.fileName = res.originalObjectName
            row.filePath = res.objectPath
            row.fileSize = res.objectSize
            row.upTime = res.gmtCreate
            this.$refs.enterpriseUpload.clearFiles() //上传成功之后清除历史记录
        },
        async uidBuilder (params, type = 'str') {
            let temp = []
            await uidBuilder(params).then(res => {
                temp = type === 'str' ? res[0] : res
            })
            return temp
        },
        // 上传前
        async beforeAvatarUpload (file) {
            const isLt2M = file.size / 1024 / 1024 < 20
            if (!isLt2M) {
                this.clientPop('err', '上传文件大小不能超过 20MB！')
            }
            return isLt2M
        },
        getObjectByRelationId () {
            if (!this.relationId) return
            return ossRequest.getObjectByRelationId({ relationId: this.relationId }).then(res => {
                this.attachTableData = res
                this.total = res.length
            })
        },
        checkCode (creditCode) {
            function checkCreditCode (creditCode) {
                const secondarray = [
                    '0',
                    '1',
                    '2',
                    '3',
                    '4',
                    '5',
                    '6',
                    '7',
                    '8',
                    '9',
                    'A',
                    'B',
                    'C',
                    'D',
                    'E',
                    'F',
                    'G',
                    'H',
                    'J',
                    'K',
                    'L',
                    'M',
                    'N',
                    'P',
                    'Q',
                    'R',
                    'T',
                    'U',
                    'W',
                    'X',
                    'Y'
                ]
                //加权因子数值
                const secondkeys = [1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28]
                //将信用代码中小写字母转成大写
                if (creditCode.length != 18) {
                    return false
                }
                var reg = /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/
                if (!reg.test(creditCode)) {
                    return false
                }

                const parityBit = getParityBit(creditCode, secondkeys, secondarray)
                if (parityBit < 0) {
                    return false
                } else {
                    return creditCode.slice(17) === secondarray[parityBit]
                }
            }

            function getParityBit (code, secondkeys, secondarray) {
                let sum = 0
                let i
                for (i = 0; i < 17; ++i) {
                    let codeIndex = secondarray.indexOf(code[i])
                    if (codeIndex === -1) {
                        return -1
                    }
                    sum += codeIndex * secondkeys[i]
                }
                i = 31 - (sum % 31)
                return i == 31 ? 0 : i
            }
            return checkCreditCode(creditCode)
        },
        unitCodeBlur (creditCode) {
            if (creditCode === '') return
            if (!this.checkCode(creditCode)) {
                this.clientPop('err', '统一信用代码不合格')
                return
            }
            openBiddingRequest.creditcodeAllInfo(creditCode).then(res => {
                if (res.data === null) {
                    this.clientPop('info', '系统外包方库中的分包商库不存在，是否新增', () => {
                        this.unitCodeState = false
                    })
                } else {
                    // 基本信息
                    this.unitCodeState = true
                    this.unitCodeState2 = false
                    this.formData.unitName = res.subcontractor.orgName
                    this.formData.outsourceType = res.subcontractor.subcontractorTypeKey
                    this.formData.registerCaptial = res.subcontractor.registerCapital
                    this.formData.legalRepresentative = res.subcontractor.deputy
                    this.formData.registerAddress = res.subcontractor.addressDetail
                    this.formData.taxpayerType = res.subcontractor.taxTypeKey //
                    this.formData.fax = res.subcontractor.fax
                    this.formData.telephone = res.subcontractor.contactTel
                    this.formData.zipCode = res.subcontractor.postCode
                    this.formData.email = res.subcontractor.email
                    // 假数据
                    res.qualificationinfoList = [{ certNo: 111 }]
                    // 资质信息
                    if (res.qualificationinfoList.length !== 0) {
                        res.qualificationinfoList.map(async (item, index) => {
                            this.$set(this.quaInfoTableData, index, {
                                billId: '',
                                certificateGrade: '',
                                certificateNo: '',
                                certificateType: '',
                                changeType: 1,
                                fileName: '',
                                filePath: '',
                                fileSize: 0,
                                gmtCreate: '',
                                gmtModified: '',
                                recordId: '',
                                upTime: '',
                                upUser: '',
                                upUserId: '',
                                validate: ''
                            })
                            this.quaInfoTableData[index].certificateGrade =
                                item.qualificationLevelName
                            this.quaInfoTableData[index].certificateNo = item.certNo
                            this.quaInfoTableData[index].certificateType = item.certTypeValue
                            this.quaInfoTableData[index].recordId = await this.uidBuilder({
                                num: 1
                            })
                        })
                    }
                    // 历史业绩
                    if (res.performanceList.length !== 0) {
                        res.performanceList.map(async (item, index) => {
                            this.$set(this.enterpriseTableData, index, {
                                billId: '',
                                changeType: 1,
                                contractAmount: 0,
                                contractName: '',
                                endTime: '',
                                fileName: '',
                                filePath: '',
                                gmtCreate: '',
                                gmtModified: '',
                                personInCharge: '',
                                projectName: '',
                                recordId: '',
                                startTime: '',
                                witness: '',
                                witnessPhone: '',
                                workContent: ''
                            })
                            this.enterpriseTableData[index].contractAmount = item.contractAmount
                            this.enterpriseTableData[index].contractName = item.contractName
                            this.enterpriseTableData[index].endTime = item.endDate
                            this.enterpriseTableData[index].personInCharge = item.projectLeader
                            this.enterpriseTableData[index].projectName = item.projectName
                            this.enterpriseTableData[index].startTime = item.startDate
                            this.enterpriseTableData[index].witness = item.witnessName
                            this.enterpriseTableData[index].witnessPhone = item.witnessTel
                            this.enterpriseTableData[index].workContent = item.workContect
                            this.enterpriseTableData[index].recordId = await this.uidBuilder({
                                num: 1
                            })
                        })
                    }
                }
            })
            console.log('历史业绩', this.enterpriseTableData)
        },
        async random19Num () {
            let temp = ''
            await uidBuilder({ num: 1 }).then(res => {
                temp = res[0]
            })
            return temp
        },
        onError () {
            this.$message({
                showClose: true,
                type: 'error',
                message: '上传失败'
            })
        },
        async tableDel (key) {
            for (let i = 0; i < this.selection[key].length; i++) {
                const tableData = key + 'TableData'
                const index = this[tableData].findIndex(value2 => {
                    return value2.recordId === value2.recordId
                })
                //后端删除
                if (key === 'enterprise' || key === 'manager') {
                    // 企业主要业绩、企业主要管理人（没有fileName,是我自己加的ifUpload）
                    if (!this[tableData][index].ifUpload) {
                        //前端删除
                        this[tableData].splice(index, 1)
                        return
                    }
                    await ossRequest
                        .deleterRecordId({ recordId: this[tableData][index].recordId })
                        .then(() => {
                            //前端删除
                            this[tableData].splice(index, 1)
                            this.$message({
                                showClose: true,
                                type: 'success',
                                message: '删除成功'
                            })
                        })
                        .catch(() => {
                            return
                        })
                    // 资质信息、附件信息
                } else {
                    if (!this[tableData][index].fileName) {
                        //前端删除
                        this[tableData].splice(index, 1)
                        return
                    }
                    await ossRequest
                        .deleterRecordId({ recordId: this[tableData][index].recordId })
                        .then(() => {
                            //前端删除
                            this[tableData].splice(index, 1)
                            this.$message({
                                showClose: true,
                                type: 'success',
                                message: '删除成功'
                            })
                        })
                }
            }
        },
        // selectionChange (key, e) {
        //     this.selection[key] = e
        // },
        // eslint-disable-next-line no-unused-vars
        cellClick (row, column, cell, event) {
            if (column.label === '招标编号') {
                this.$router.push({
                    path: './biddingApplicationShow',
                    query: { tenderId: row.billId }
                })
            }
        },
        handleSelectionChange (e) {
            console.log(e)
        },
        enterpriseAddInputBlur () {
            if (this.formData.contractName) {
                enrollRequest.achievementCreate(this.formData).then(res => {
                    console.log(res)
                    // 增加包件id，用于编辑
                    // this.formData.dtlId = res
                })
            }
        },
        // 资质信息增加
        async quaInfoAdd (table) {
            table.push({
                billId: '',
                changeType: 1,
                contractAmount: 0,
                contractName: '',
                endTime: '',
                fileName: '',
                filePath: '',
                gmtCreate: '',
                gmtModified: '',
                personInCharge: '',
                projectName: '',
                recordId: await this.uidBuilder({
                    num: 1
                }),
                startTime: '',
                witness: '',
                witnessPhone: '',
                workContent: '',
                frontState: 1
            })
        },
        // 历史业绩增加
        async enterpriseAdd (table) {
            table.push({
                billId: '',
                changeType: 1,
                contractAmount: 0,
                contractName: '',
                endTime: '',
                fileName: '',
                filePath: '',
                gmtCreate: '',
                gmtModified: '',
                personInCharge: '',
                projectName: '',
                recordId: await this.uidBuilder({
                    num: 1
                }),
                startTime: '',
                witness: '',
                witnessPhone: '',
                workContent: '',
                frontState: 1
            })
        },
        async getTenderData () {
            await equipmentProcurementRequest.applyGetById({ id: this.tenderId }).then(res => {
                this.formData.projectName = res.tenderName
                this.formData.tenderApplyId = res.billId
                this.formData.tenderApplyNo = res.billNo
                this.formData.applyUnit = res.tenderUser
                this.formData.tenderType = res.tenderClass
                this.formData.enrollTime = this.getNowDate()
            })
        },
        getPackage () {
            equipmentProcurementRequest
                .packageListByEntity({
                    limit: 20,
                    page: 1,
                    tenderApplyId: this.tenderId
                })
                .then(async res => {
                    if (res.length === 0) return
                    this.packageTableData = res
                    res.forEach(item => {
                        this.formData.packageName += item.name + '，'
                    })
                    this.formData.packageName = this.formData.packageName.substr(
                        0,
                        this.formData.packageName.length - 1
                    )
                    // 前端显示的分包商
                    // this.pagination.total = res.totalCount || res.length
                })
        },
        onChangeTab (e) {
            const height = $('#' + e.name).offset().top
            $.scrollTo(height - this.topHeight, 500)
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            this.clickTabFlag = true
            // 动画结束后，恢复状态
            setTimeout(() => {
                this.clickTabFlag = false
            }, 600)
        },
        // 获取最后一个内容区域的高度，计算底部空白
        getLastConHeight (arr) {
            let si = setInterval(() => {
                // 因为dom异步加载，通过轮询找到渲染后的dom，获取高度
                if (document.getElementById(arr[length - 1] + 'Con')) {
                    const lastConHeight = document.getElementById(
                        arr[length - 1] + 'Con'
                    )?.offsetHeight
                    this.lastConHeight = lastConHeight
                    clearInterval(si)
                    si = null
                }
            }, 100)
        },
        delData () {
            // bidNoticeRequest.batchDelete([this.billId]).then(res => {
            //     this.$message({
            //         showClose: true,
            //         type: 'success',
            //         message: res.message
            //     })
            //     this.$router.push({
            //         path: './biddingApplicationEdit',
            //         query: { billid: this.tenderId, seat: 'reg' }
            //     })
            // })
        },
        // getData () {
        //     bidNoticeRequest.findById(this.billId).then(res => {
        //         this.formData = res
        //     })
        // },
        showBidding () {
            if (!this.tenderId) return // 前期需求可切换，现在不需要
            this.$notify.closeAll()
            this.$notify({
                title: '查看招标详情',
                dangerouslyUseHTMLString: true,
                message: `正式环境：客户端打开新页面<br>
              测试环境：手动打开新页面<br>
              <textarea cols="35" rows="10">http://localhost:8080/biddingApplicationShow?tenderId=${this.tenderId}</textarea>
              `,
                duration: 0
            })
            // this.$router.push({
            //     path: './biddingApplicationShow',
            //     query: { tenderId: this.tenderId }
            // })
        },
        // submit () {
        //     console.log('asdasd', this.enterpriseTableData)
        //     // 处理地址
        //     // 地址
        //     const temp = JSON.parse(this.formData.addressCode)
        //     const address = this.formData.addressCode !== '' ? temp.address.join(',') : ''
        //     const code = this.formData.addressCode !== '' ? temp.code.join(',') : ''
        //     const detail = temp.detail
        //     // 固定工作地址
        //     const temp2 = JSON.parse(this.formData.fixAddressCode)
        //     const address2 = this.formData.fixAddress !== '' ? temp2.address.join(',') : ''
        //     const code2 = this.formData.fixAddress !== '' ? temp2.code.join(',') : ''
        //     const detail2 = temp2.detail
        //     this.formData.address = address
        //     this.formData.addressCode = code
        //     this.formData.addressDetail = detail
        //     this.formData.fixAddress = address2
        //     this.formData.fixAddressCode = code2
        //     this.formData.fixAddressDetail = detail2
        //     // 企业主要业绩、资质信息、企业主要管理人、附件信息
        //     this.formData.history = this.enterpriseTableData
        //     this.formData.applyQualifications = this.quaInfoTableData
        //     this.formData.applyPersonnels = this.managerTableData
        //     this.formData.attachments = this.attachTableData
        //     this.formData.attachments.forEach(value => {
        //         delete value.recordId
        //     })
        //     console.log('formData', this.formData)
        //     // 发送请求
        //     enrollRequest.create(this.formData).then(() => {
        //         this.$message({
        //             showClose: true,
        //             type: 'success',
        //             message: '提交成功'
        //         })
        //         // 重置地址
        //         this.formData.addressCode = ''
        //         this.formData.fixAddressCode = ''
        //     })
        //     // bidNoticeRequest.update(this.formData).then(res => {
        //     //     // this.dialogVisible = false
        //     //     this.$message({
        //     //         showClose: true,
        //     //         type: 'success',
        //     //         message: res.message
        //     //     })
        //     //     this.$router.push({
        //     //         path: './biddingApplicationEdit',
        //     //         query: { billid: this.tenderId, seat: 'reg' }
        //     //     })
        //     // })
        // },
        getNowDate () {
            // 个位数前补0
            const zeroFill = function (num) {
                if (parseInt(num) < 10) {
                    num = '0' + num
                }
                return num
            }
            let nowtime = new Date()
            nowtime =
                zeroFill(nowtime.getFullYear()) +
                '-' +
                zeroFill(nowtime.getMonth() + 1) +
                '-' +
                zeroFill(nowtime.getDate())
            return nowtime
            // this.$set(this.formData, 'applyTime', nowtime)
        },
        cellClsNm ({ column }) {
            if (column.label === '') {
                return 'fixed-left'
            }
        },
        cellMouseEnter (row) {
            this.MouseEnterId = row.id
        },
        cellMouseLeave () {
            this.MouseEnterId = 0
        },
        reset () {
            this.formData = {
                applyPersonnels: [
                    {
                        certNo: '',
                        endTime: '',
                        filePath: '',
                        idCardNo: '',
                        name: '',
                        phone: '',
                        recordId: '',
                        startTime: '',
                        type: ''
                    }
                ],
                applyQualifications: [
                    {
                        certificateGrade: '',
                        certificateNo: '',
                        certificateType: '',
                        fileName: '',
                        filePath: '',
                        fileSize: 0,
                        recordId: '',
                        upTime: '',
                        upUser: '',
                        upUserId: '',
                        validateEnd: '',
                        validateStart: ''
                    }
                ],
                attachments: [
                    {
                        fileName: '',
                        filePath: '',
                        size: 0,
                        type: '',
                        upLoadTime: ''
                    }
                ],
                baseInfo: {
                    address: '',
                    addressCode: '',
                    addressDetail: '',
                    applyId: '',
                    certificateScene: 0,
                    certifiedConstructorNum: 0,
                    email: 'email@email.com', //假数据
                    enterpriseBase: '',
                    fax: '123', //假数据
                    fixAddress: '',
                    fixAddressCode: '',
                    fixAddressDetail: '',
                    fixedTelephone: '',
                    isAbroad: 0,
                    legalRepresentative: '法人代表',
                    middlePosition: 0,
                    middleTechnology: 0,
                    outsourceType: '',
                    projectName: '',
                    proxyUser: '',
                    qualificationLevel: 3, //假数据
                    registerCaptial: 0,
                    safetyNum: 0,
                    socialNum: 0,
                    taxpayerType: '',
                    telephone: '',
                    unitCode: '',
                    unitName: ''
                },
                history: [
                    {
                        contractAmount: 0,
                        contractName: '',
                        endTime: '',
                        filePath: '',
                        personInCharge: '',
                        projectName: '',
                        recordId: '',
                        startTime: '',
                        witness: '',
                        witnessPhone: '',
                        workContent: ''
                    }
                ],
                packageIds: []
            }
            this.enterpriseTableData = []
            this.quaInfoTableData = []
            this.managerTableData = []
            this.attachTableData = []
        }
    }
}
</script>

<style lang="scss" scoped>
.title {
    position: absolute;
    top: 10px;
    right: 30px;
}
::v-deep.require::first-letter {
    color: red !important;
}
// .buttons {
//     display: flex;
//     justify-content: center;
//     .el-button {
//         padding: 15px 50px;
//     }
// }
// .form {
//     margin-top: 10px;
// }

// .e-table {
//     background: #fff;
// }

// .upload {
//     margin: 20px auto;
//     display: flex;
//     justify-content: center;
//     text-align: center;
// }

// .upload-demo {
//     display: flex;
//     justify-content: center;
//     align-items: center;
// }

/* 滚动条 */
.e-form {
    ::-webkit-scrollbar {
        width: 12px;
        height: 15px;
    }

    ::-webkit-scrollbar-track {
        -webkit-border-radius: 10px;
        border-radius: 10px;
        background: #f6f7f9;
    }

    ::-webkit-scrollbar-thumb {
        -webkit-border-radius: 10px;
        border-radius: 10px;
        background: rgba(204, 204, 204, 0.8);
    }
    ::-webkit-scrollbar-thumb:window-inactive {
        background: rgba(204, 204, 204, 0.4);
    }
}

// 附件栏
.affix {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .right {
        display: flex;
        align-items: center;
        i {
            margin-left: 10px;
        }
    }
}
// .buttons .el-button {
//     padding: 0;
// }
</style>
